#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <string>
#include <stack>
#include <set>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;
ll a[10]={1,2,3,4,5,6,7,8,9,10};
bool judge(){
    for(ll i=1;i<5;i++){
        if(a[i]<a[i-1])return false;
    }
    if(a[5]<a[0])return false;
    for(ll i=6;i<10;i++){
        if(a[i]<a[i-1]||a[i]<a[i-5])return false;
    }
    return true;
}

int main()
{
    IOS;

    ll ans=0;
    do{ 
        if(judge())ans++;

    }while (next_permutation(a,a+10));
    cout<<ans<<endl;
    getchar();
    getchar();
    return 0;
}
